<template>
	<el-drawer title="应收款详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-form>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="关联合同" prop="contractId">{{form.title}}
							</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="责任人" prop="accountId">{{form.userName}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="应收日期" prop="receivablesTime">{{form.receivablesTime}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="应收金额" prop="unReceived">{{form.unReceived}}</el-form-item>
						</el-col>
					</el-row>
					<el-form-item label="应收款备注">
						<div v-html="form.remark"></div>
					</el-form-item>
					<el-form-item label="相关附件" v-if="form.attachId!=''">
						<attach-menu :attachIds="form.attachId" :roleFlag="3" :preview="true"></attach-menu>
					</el-form-item>
					<scTable ref="table" :params="{receivablesId:form.receivablesId}" :apiObj="apiObj" row-key="recordId" stripe remoteSort remoteFilter>
						<el-table-column label="收款人" prop="userName" width="100"></el-table-column>
						<el-table-column label="收款金额" prop="amount" width="150">
							<template #default="scope">
								{{ scope.row.amount }}/元
							</template>
						</el-table-column>
						<el-table-column label="收款日期" prop="payeeTime" width="100"></el-table-column>
						<el-table-column label="收款类型" prop="payeeTypeName" width="100"></el-table-column>
						<el-table-column label="操作" fixed="right" align="right" width="100">
							<template #default="scope">
								<el-button-group>
									<el-popconfirm title="确定删除吗？" @confirm="table_del(scope.row, scope.$index)">
										<template #reference>
											<el-button text type="primary" size="small">删除</el-button>
										</template>
									</el-popconfirm>
								</el-button-group>
							</template>
						</el-table-column>
					</scTable>
				</el-form>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	emits: ['success', 'closed'],
	components: {
		AttachMenu,
	},
	data() {
		return {
			apiObj:this.$API.finance.contract.getContractReceivablesRecordList,
			loading: false,
			form: {
				receivablesId:"",
				title:"",
				userName:"",
				receivablesTime:"",
				unReceived:"",
				remark:"",
				attachId:""
			},
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},
		//删除
		async table_del(row) {
			var res = await this.$API.finance.contract.deleteContractReceivablesRecord.post({recordId:row.recordId});
			if (res.code == 200) {
				this.$refs.table.refresh()
				this.$message.success("删除成功")
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		//表单注入数据
		setData(data){
			this.form.receivablesId = data.receivablesId
			this.form.title=data.title
			this.form.userName=data.userName
			this.form.attachId=data.attachId
			this.form.receivablesTime=data.receivablesTime
			this.form.unReceived=data.unReceived
			this.form.remark=data.remark
		},
	}
}
</script>

<style>
</style>
